package main

import (
	"database/sql"
	"fmt"

	_ "github.com/go-sql-driver/mysql"
)
// test
func main() {
	fmt.Println()
	// 数据库信息
	dsn := "root:root@tcp(127.0.0.1:3306)/go_mysql"
	// 连接数据库
	db, err := sql.Open("mysql", dsn)
	if err != nil {
		fmt.Printf("init db failed,err:%v\n", err)
	}
	err = db.Ping()
	if err != nil {
		fmt.Println("failed to conn mysql")
	}
	querystr := "select * from `user`"
	result := db.QueryRow(querystr)
	fmt.Println(result)
	defer db.Close()
}
